//
//  LLCourseEditView.m
//  LoveLove
//
//  Created by 达迩科技 on 2019/4/10.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLCourseEditView.h"

@implementation LLCourseEditView

- (instancetype)init {
    self = [super init];
    if(self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

-(void)setup{
    
    LLButton *maskButton = [[LLButton alloc] initWithFrame:self.bounds];
    maskButton.backgroundColor = LLColor(145, 148, 153);
    [maskButton addTarget:self action:@selector(didSelectCancle) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:maskButton];
    
    UIView *bgview = [[UIView alloc] initWithFrame:CGRectMake(50, LLScreenHeight/2-240/2, LLScreenWidth-100, 240)];
    bgview.layer.masksToBounds = YES;
    bgview.layer.cornerRadius = 10;
    bgview.backgroundColor = LLWhiteColor;
    [maskButton addSubview:bgview];
    
    NSArray *titleArray = @[@"更多操作",@"分享",@"下架",@"删除"];
    
    for (int i=0; i<titleArray.count; i++) {
        LLButton *button = [LLInitBaseViewTool buttonWithTitle:titleArray[i] image:nil titleColor:LLColor(236, 2, 2) font:18];
        if (i==0) {
            button.userInteractionEnabled = NO;
            [button setTitleColor:LLColorRGB(0) forState:0];
        }
        button.frame = CGRectMake(0, 60*i, bgview.width, 60);
        button.tag = i;
        [button addTarget:self action:@selector(didSelecttype:) forControlEvents:UIControlEventTouchUpInside];
        [bgview addSubview:button];
        
        UIView *lineview = [[UIView alloc] initWithFrame:CGRectMake(0, 59.5+60*i, bgview.width, 0.5)];
        lineview.backgroundColor = LLColorRGBAlpha(67, 67, 67, 0.5);
        [bgview addSubview:lineview];
        
        if (i==3) {
            [lineview removeFromSuperview];
        }
        
    }
    
    UIButton *cnacleButton = [LLInitBaseViewTool buttonWithTitle:nil image:@"矩形 5 拷贝 3" titleColor:nil font:0];
    cnacleButton.frame = CGRectMake(LLScreenWidth-50-14.5, LLScreenHeight/2-240/2-14.5, 29, 29);
    [cnacleButton setBackgroundColor:LLColorRGB(224)];
    [cnacleButton addTarget:self action:@selector(didSelectCancle) forControlEvents:UIControlEventTouchUpInside];
    cnacleButton.layer.masksToBounds = YES;
    cnacleButton.layer.cornerRadius = 14.5;
    [self addSubview:cnacleButton];
    
    
}

- (void)didSelecttype:(LLButton *)button{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectButtonCaouzuo:didClickItem:)]) {
        [self.delegate didSelectButtonCaouzuo:self didClickItem:button.tag];
    }
}

- (void)didSelectCancle{
    self.hidden = YES;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
